#include "Waypoint.h"
#include "mapmethods.h"

void Waypoint::calcPos(qreal centerLat, qreal centerLon, int mapZoom, int tdim, int screenH, int screenW){
    QPointF wayP(MapMethods::tileForCoordinate(latitude, longitude, mapZoom));
    QPointF centerP(MapMethods::tileForCoordinate(centerLat, centerLon, mapZoom));
    QPointF dx = centerP - wayP;
    QPointF delta = dx * qreal(tdim);
    QPointF center(screenW/2,screenH/2);

    drawPoint = (center - delta).toPoint();
}

void Waypoint::setPosition(qreal ty, qreal tx, int zoom){
    latitude = MapMethods::latitudeFromTile(ty, zoom);
    longitude = MapMethods::longitudeFromTile(tx, zoom);
}
